import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main2 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < n; i++) {
            int a = in.nextInt();
            set.add(a);
        }
        for(int i = 0; i < m; i++) {
            int b = in.nextInt();
            set.add(b);
        }
        Object[] ret = set.toArray();
        for (int i = 0; i < ret.length - 1; i++) {
            System.out.print(ret[i] + " ");
        }
        System.out.print(ret[ret.length - 1]);
    }
}